import { createApp } from 'vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import router from './router'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import { setupRouterGuard } from './router/guard'
import { registerSvgComponents } from '@/components/svgs'

// 引入图标样式
import './assets/css/icon.css'

const app = createApp(App)

// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 注册所有自定义的 svg 组件
registerSvgComponents(app)

app.use(createPinia())
app.use(router)

// 设置导航守卫
setupRouterGuard(router)

app.use(ElementPlus)
app.mount('#app')
